import pytest

from api.shop_api import Api
from common.assert_tools import common_assert
from common.read_json_file import read_json_data


class TestShopLogin(object):
    data = read_json_data("../data/login_data.json")

    @pytest.mark.parametrize("desc,req_data,status_code,code,msg",data)
    def test_login(self,desc,req_data,status_code,code,msg):
        resp = Api.login(req_data)

        # print(desc,":",resp.json())
        # 格式化输出，让测试结果更清晰
        print("\n" + "=" * 80)
        print(f"测试用例: {desc}")
        print(f"请求数据: {req_data}")
        print(f"响应结果: {resp.json()}")
        print(f"期望结果: HTTP状态码={status_code}, code={code}, msg={msg}")
        print("=" * 80)

        common_assert(resp,status_code,code,msg)